<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;
use Closure;

class MembersRequest extends FormRequest
{

    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }


    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public static function rules()
    {
        return [
            'openid' => 'required|unique:members',
            'phone' => 'required|unique:members',
            'name' => 'required|min:2',
            'hospital' => 'required|min:3',
            'address'  => 'required',
            'section'  => 'required',
            'verification_key' => 'required|string',
            'verification_code' => 'required|string',
        ];
    }

    public static function message()
    {
        return [
            'openid.required' => '缺少必要参数',
            'openid.unique' => 'openid已存在',
            'phone.required' => '缺少必要参数',
            'phone.unique' => '手机号已存在',
        ];
    }
}
